<?php
/**
 * Created by PhpStorm.
 * User: zd
 * Date: 2018/11/8
 * Time: 16:04
 */

namespace app\api\model;


class CardBrowse extends BaseModel
{
    protected  $autoWriteTimestamp = true;
    protected $updateTime   = false;


    /**
     * 与user表一对一关联
     * @return \think\model\relation\BelongsTo
     */
    public  function users(){
        return $this->belongsTo('user','user','id');
    }
    /**
     * 创建浏览对象
     * @param $data
     * @return $this
     */
    public static function createBrowse($data){
        return self::create($data);
    }

    /**
     * 获取浏览记录
     * @param $w_id
     * @return false|\PDOStatement|string|\think\Collection
     */
    public static function getBrowse($w_id){
        return self::with(['users'])->where('w_id','=',$w_id)->select();
    }

    /**
     * 删除浏览记录
     * @param $id
     * @return int
     */
    public static function deleteBrowse($id){
       return self::destroy($id);
    }

}